package com.lanchetech.dao;
import java.util.Date;

import com.lanchetech.bean.request.PageReq;import com.lanchetech.bean.vo.UserAgentLevelVO;import com.lanchetech.entity.UserAgentLevel;
import org.apache.ibatis.annotations.Mapper;import org.apache.ibatis.annotations.Param;import java.util.List;

@Mapper
public interface UserAgentLevelMapper {
    int deleteByPrimaryKey(Long id);

    int insert(UserAgentLevel record);

    int insertSelective(UserAgentLevel record);

    UserAgentLevel selectByPrimaryKey(Long id);

    int updateByPrimaryKeySelective(UserAgentLevel record);

    int updateByPrimaryKey(UserAgentLevel record);

    int updateBatch(List<UserAgentLevel> list);

    int updateBatchSelective(List<UserAgentLevel> list);

    int batchInsert(@Param("list") List<UserAgentLevel> list);

    List<UserAgentLevelVO> findAllPage(PageReq req);

    List<UserAgentLevel> findAllByLocationIds(@Param("locationIds") List<Long> locationIds);

    List<UserAgentLevel> findAllByLocationIdsAndUserId(@Param("locationIds") List<Long> locationIds, @Param("userId") Long userId);

    List<UserAgentLevel> findAllByLocationIdsAndExpireTime(@Param("locationIds") List<Long> locationIds,@Param("maxExpireTime")Date maxExpireTime);

    UserAgentLevel findOneByIdAndTypeAndExpireTime(@Param("id")Long id, @Param("type")Byte type, @Param("maxExpireTime")Date maxExpireTime);

    List<UserAgentLevel> findAllByUserIdAndExpireTime(@Param("userId")Long userId, @Param("maxExpireTime")Date maxExpireTime);

    UserAgentLevel findOneByLocationIdAndExpireTime(@Param("locationId")Long locationId, @Param("maxExpireTime")Date maxExpireTime);

    UserAgentLevel findOneByLocationIdAndUserId(@Param("locationId")Long locationId,@Param("userId")Long userId);

    int updateExpireTimeById(@Param("updatedExpireTime")Date updatedExpireTime,@Param("id")Long id);

    Long countByUserIdAndExpireTimeGreaterThan(@Param("userId")Long userId,@Param("minExpireTime")Date minExpireTime);

    UserAgentLevel findOneByUserId(@Param("userId")Long userId);
}